import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Photo Viewer'),
          actions: [
            IconButton(
              icon: const Icon(Icons.center_focus_strong),
              onPressed: () {
                // 这里可以通过 TransformationController 实现重置功能
              },
            ),
          ],
        ),
        body: InteractiveViewer(
          minScale: 0.1,
          maxScale: 5.0,
          boundaryMargin: const EdgeInsets.all(20),
          child: Image.network(
            'https://picsum.photos/1200/800', // 使用一张大图
            fit: BoxFit.cover,
            loadingBuilder: (context, child, loadingProgress) {
              if (loadingProgress == null) return child;
              return Center(
                child: CircularProgressIndicator(
                  value: loadingProgress.expectedTotalBytes != null
                      ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes!
                      : null,
                ),
              );
            },
          ),
        ),
      ),
    );
  }
}
